﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace MessengerBot
{
    /// <summary>
    /// Implements <see cref="ICommandBasedSystem"/> to show help.
    /// </summary>
    internal sealed class HelpSystem : ICommandBasedSystem
    {
        #region ICommandBasedSystem Members

        /// <summary>
        /// Retrieve all the <see cref="Type"/> objects for the commands implemented by the system.
        /// Each has to be tagged with an appropriate <see cref="CommandAttribute"/>.
        /// </summary>
        /// <returns>
        /// A collection of types implementing <see cref="ICommand"/>.
        /// </returns>
        public IEnumerable<Type> GetCommands()
        {
            yield return typeof(HelpCommand);
        }

        /// <summary>
        /// This method is called when a session is started between the bot and a user.
        /// </summary>
        /// <param name="bot">
        /// The <see cref="Bot"/> instance that manages the <paramref name="session"/>.
        /// </param>
        /// <param name="session">
        /// The <see cref="Session"/> that was started.
        /// </param>
        /// <returns>
        /// Returns a state object that the systemwants to keep while the session is alive,
        /// which will be passed as the state argument to other methods on the
        /// <see cref="ISystem"/> interface.
        /// </returns>
        public object SessionStarted(Bot bot, Session session)
        {
            return null;
        }

        /// <summary>
        /// This method is called when a session ends.
        /// </summary>
        /// <param name="bot">
        /// The <see cref="Bot"/> instance that managed the <paramref name="session"/>.
        /// </param>
        /// <param name="session">
        /// The <see cref="Session"/> that ended.
        /// </param>
        /// <param name="state">
        /// The state object that was originally obtained through <see cref="ISystem.SessionStarted"/>.
        /// </param>
        public void SessionEnded(Bot bot, Session session, object state)
        {
        }

        /// <summary>
        /// This method is called when a message is received from the user.
        /// </summary>
        /// <param name="bot">
        /// The <see cref="Bot"/> instance that manages the <paramref name="session"/>.
        /// </param>
        /// <param name="session">
        /// The <see cref="Session"/> that was started.
        /// </param>
        /// <param name="state">
        /// The state object that was originally obtained through <see cref="ISystem.SessionStarted"/>.
        /// </param>
        /// <param name="message">
        /// The message that was received.
        /// </param>
        public void MessageReceived(Bot bot, Session session, object state, string message)
        {
        }

        #endregion
    }
}